//
//  tooles.m
//  huoche
//
//  Created by kan xu on 11-1-22.
//  Copyright 2011 paduu. All rights reserved.
//

#import "tooles.h"
#import "DataPlist.h"

@implementation tooles

#define kDeviceWidth [UIScreen mainScreen].bounds.size.width
#define KDeviceHeight [UIScreen mainScreen].bounds.size.height

+(float)DeviceVersion
{
    return [[UIDevice currentDevice].systemVersion doubleValue];
}

+(int)getPlistValueForKey:(NSString*)aStr
{
    NSMutableDictionary *levelDic = [DataPlist openPlistFromDocumentWithName:@"Setting" AndTheType:@"plist"];
    NSLog(@"fffff:%@",levelDic);
    if(!levelDic)
    {
        NSLog(@"not exist");
        levelDic = [NSMutableDictionary dictionary];
        [levelDic setValue:@"1" forKey:@"level"];
        [DataPlist writePlistToDocumentWithDic:levelDic WithName:@"Setting" AndTheType:@"plist"];
        return [[levelDic valueForKey:aStr] intValue];
    }
    return [[levelDic valueForKey:aStr] intValue];
}

+(void)setPlistValue:(int)aValue ForKey:(NSString*)aStr
{
    NSMutableDictionary *levelDic = [DataPlist openPlistFromDocumentWithName:@"Setting" AndTheType:@"plist"];
    [levelDic setValue:[NSString stringWithFormat:@"%d",aValue] forKey:aStr];
    [DataPlist writePlistToDocumentWithDic:levelDic WithName:@"Setting" AndTheType:@"plist"];
}

+(NSString*)YJMusicNameByIndex:(NSString*)aIndex
{
    //book/com.fuzhi123.baijiaxing/audio/01.mp3
    NSString *flag = @"book/com.fuzhi123.baijiaxing/audio/";
    return [aIndex substringFromIndex:flag.length];
}

+(NSString*)YJIconNameByIndex:(NSString*)aIndex
{
    //book/com.fuzhi123.shangshu/audio/01.mp3
    NSString *flag = @"book/com.fuzhi123.baijiaxing/icon/";
    return [aIndex substringFromIndex:flag.length];
}

+(NSString*)softwareVersion
{
    return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
}

@end
